package models;

import java.lang.String;import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import models.BasicModel;import play.db.jpa.GenericModel;

@Entity
@Table(name = "type_name")
public class TypeName extends BasicModel {

	// 哪个东西的类型
	@Column(name = "attrubite")
	public String attrubite;

	// 类型的中文名
	@Column(name = "type_name")
	public String typeName;

	// 排序
	@Column(name = "weight", columnDefinition = "int default 0", nullable = false)
	public int weight;

	// 获取对应类型的数组
	public static String[][] getTypeNameList(String type) {
		List<TypeName> tnList = TypeName.find(
				"attrubite = ? order by weight, createTime", type).fetch();
		String[][] str = new String[tnList.size()][2];
		for (int i = 0; i < tnList.size(); i++) {
			str[i][0] = tnList.get(i).id;
			str[i][1] = tnList.get(i).typeName;
		}
		return str;
	}
}